package com.message.factory;

import com.message.*;

import java.util.Arrays;

public class InputTextToMessageToFactory {
    public static Message toMessage(String[] inputArray) {

        switch (inputArray[0]) {
            case "1":
                return new ChatReqMessage(inputArray[1], inputArray[2]);
            case "2":
                return new ChatGroupCreateMessage(inputArray[1], Arrays.asList(inputArray[2].split(",")));
            case "3":
                return new GroupChatReqMessage(inputArray[1], inputArray[2]);
            case "4":
                return new ExitGroupChatReqMessage(inputArray[1]);
            case "5" :
                return new ChatLoginOutMessage();
            default:
                return new DefaultMessage() {
                    @Override
                    public int getMessageType() {
                        return 0;
                    }
                };
        }

    }
}

